package cn.anecansaitin.whimsy.common.register;

import cn.anecansaitin.whimsy.Whimsy;
import cn.anecansaitin.whimsy.common.ICodeObject;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.Item;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister;

public class ModCreativeTabs {
    public static final DeferredRegister<CreativeModeTab> TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, Whimsy.MODID);
    public static final DeferredHolder<CreativeModeTab, CreativeModeTab> MOD_TAB = TABS.register(Whimsy.MODID + "_tab", () ->
            CreativeModeTab.builder()
                    .title(Component.translatable("itemGroup." + Whimsy.MODID + ".tab"))
                    .icon(() -> ModItems.ROCK_SCEPTRE.get().getDefaultInstance())
                    .displayItems((p, o) -> {
                        for (DeferredHolder<Item, ? extends Item> entry : ModItems.ITEMS.getEntries()) {
                            if (entry.get() instanceof ICodeObject) {
                                continue;
                            }

                            o.accept(entry.get().getDefaultInstance());
                        }
                    })
                    .withTabsBefore(CreativeModeTabs.SPAWN_EGGS)
                    .build());
}
